package com.example.demo.utils.thread;

import com.example.demo.mybatisPlus.entity.SysOperLog;
import com.example.demo.mybatisPlus.mapper.SysOperLogMapper;
import com.example.demo.utils.date.DateUtils;
import com.example.demo.utils.spring.SpringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.TimerTask;

/**
 * 异步工厂（产生任务用）
 * 
 * @author liuhulu
 *
 */
public class AsyncFactory
{
    private static final Logger logger = LoggerFactory.getLogger(AsyncFactory.class);

    /**
     * 操作日志记录
     * 
     * @param operLog 操作日志信息
     * @return 任务task
     */
    public static TimerTask recordOper(final SysOperLog operLog)
    {
        return new TimerTask()
        {
            @Override
            public void run()
            {
                operLog.setOperTime(DateUtils.now());
                // 远程查询操作地点
                SpringUtils.getBean(SysOperLogMapper.class).insert(operLog);
            }
        };
    }
}
